home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / wnos / wn941101 / mbuf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-10  |  2.2 KB  |  65 lines

  1. #ifndef    _MBUF_H
  2. #define _MBUF_H
  3.  
  4. #if !defined(__STDIO_DEF_) && !defined(__STDIO_H)
  5. #  include <stdio.h>
  6. #endif
  7.  
  8. #ifndef _GLOBAL_H
  9. #include "global.h"
  10. #endif
  11.  
  12. /* Basic message buffer structure */
  13. struct mbuf {
  14.     struct mbuf *next;    /* Links mbufs belonging to single packets */
  15.     struct mbuf *anext;    /* Links packets on queues */
  16.     int16 size;        /* Size of associated data buffer */
  17.     int refcnt;        /* Reference count */
  18.     struct mbuf *dup;    /* Pointer to duplicated mbuf */
  19.     char *data;        /* Active working pointers */
  20.     int16 cnt;
  21. };
  22. #define    NULLBUF    (struct mbuf *)0
  23. #define    NULLBUFP (struct mbuf **)0
  24.  
  25. #define    PULLCHAR(bpp)\
  26.  ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  27.  ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  28.  
  29. /* In mbuf.c: */
  30. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  31. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  32. void free_q __ARGS((struct mbuf **q));
  33. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  34. struct mbuf *alloc_mbuf __ARGS((int16 size));
  35. struct mbuf *ambufw __ARGS((int16 size));
  36. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  37. struct mbuf *dequeue __ARGS((struct mbuf **q));
  38. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  39. struct mbuf *free_p __ARGS((struct mbuf *bp));
  40. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  41. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  42. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  43. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  44. int16 len_p __ARGS((struct mbuf *bp));
  45. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  46. int16 len_q __ARGS((struct mbuf *bp));
  47. int32 pull32 __ARGS((struct mbuf **bpp));
  48. int32 get32 __ARGS((char *cp));
  49. int16 pull16 __ARGS((struct mbuf **bpp));
  50. void refiq __ARGS((void));
  51. void mbuf_crunch __ARGS((struct mbuf **bpp));
  52. int16 get16 __ARGS((char *cp));
  53. int pullchar __ARGS((struct mbuf **bpp));
  54. char *put16 __ARGS((char *cp,int16 x));
  55. char *put32 __ARGS((char *cp,int32 x));
  56. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  57. void iqstat __ARGS((void));
  58.  
  59. #define    AUDIT(bp)    audit(bp,__FILE__,__LINE__)
  60.  
  61.  
  62. #endif    /* MBUF_H */
  63.  
  64.  
  65.